package com.eagle.gennewdata;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.eagle.gennewdata.logic.INewData;
import com.eagle.gennewdata.logic.NewDataImpl;
import com.eagle.gennewdata.untl.ZLibUtils;

@SuppressWarnings("serial")
public class InsertnewdataServlet extends HttpServlet {

//	@Override
//	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
//			throws ServletException, IOException {
//		// TODO Auto-generated method stub
//		super.doGet(req, resp);
//		String strHtml = CheckSumFun
//				.getUrlHtmlText("http://localhost:8889/listnewdata", "UTF-8");
//		String strHtm2 = "";
//		try {
//			byte[] byteXml = ZLibUtils.compress(strHtml.getBytes("UTF-8"));
//			CheckSumFun.PostDataForUrl("http://localhost:8889/insertnewdata", byteXml);
//		} catch (Exception e) {
//			// TODO: handle exception
//		}
//	}


	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		//super.doPost(req, resp);

		INewData inewdata = new NewDataImpl();
		// inewdata.PaserXmlStream(req.getInputStream());
		try {
			byte[] byteXml = ZLibUtils.decompress(req.getInputStream());
			inewdata.PaserXmlByteArray(byteXml);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
